home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok58.lha
/
SysDis
/
SysDis.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
5KB
|
201 lines
(*---------------------------------------------------------------------------
:Program. SysDis.mod
:Contents. Disassembler für die System-Routinen
:Author. Christian Stiens
:Address. Heustiege 2, W-4710 Lüdinghausen
:Copyright. PD
:Language. Oberon
:Translator. Amiga Oberon V2.09 [fbs]
:History. V1.0, 23-Aug-91
:Imports. MyArguments, DisAss
---------------------------------------------------------------------------*)
MODULE SysDis;
IMPORT
io,Break,
c : Conversions,
arg : MyArguments, (* kompatibel zu Arguments, erlaubt bei WB-Start die
Eingabe der Argumente über Tastatur.
Liegt aus rechtlichen Gründen nicht bei *)
da : DisAss,
d : Dos,
e : Exec,
st : Strings,
sys : SYSTEM;
CONST
error = 0;
library = 1;
device = 2;
resource = 3;
usage = "Usage: SysDis <lib|dev|resourcename> <offset> [<numlines>]\n or: SysDis <adr> [<numlines>]\n";
VAR
ioreq : e.IOStdReq;
name : ARRAY 80 OF CHAR;
str : ARRAY 80 OF CHAR;
lib : e.LibraryPtr;
ptr : POINTER TO STRUCT jmp:INTEGER; adr:LONGINT END;
offs : LONGINT;
lines : LONGINT;
size : INTEGER;
type : INTEGER;
adr : e.ADDRESS;
line : da.Line;
unit : LONGINT;
PROCEDURE GetType(VAR str: ARRAY OF CHAR): INTEGER;
VAR point : INTEGER;
str2 : ARRAY 80 OF CHAR;
BEGIN
IF str[0] = 0X THEN RETURN error END;
point := st.Occurs(str,".");
IF point < 0 THEN
st.Append(str,".library");
END;
point := st.Occurs(str,".");
IF point < 0 THEN RETURN error END;
st.Cut(str,point+1,st.Length(str)-point,str2);
IF str2 = "library" THEN RETURN library
ELSIF str2 = "device" THEN RETURN device
ELSIF str2 = "resource" THEN RETURN resource
END;
RETURN error;
END GetType;
PROCEDURE Usage;
BEGIN
io.closeDelay := 150;
io.WriteString(usage);
HALT(0)
END Usage;
BEGIN
lib := NIL;
IF arg.NumArgs() = 0 THEN Usage END;
arg.GetArg(1,str);
IF str[0] = "?" THEN Usage END;
IF c.StringToInt(str,adr) THEN
IF arg.NumArgs() > 1 THEN
arg.GetArg(2,str);
IF ~c.StringToInt(str,lines) THEN Usage END;
ELSE
lines := -1;
END;
ELSE
IF arg.NumArgs() < 2 THEN Usage END;
arg.GetArg(1,name);
type := GetType(name);
IF type = error THEN
io.WriteString("Wrong name\n");
HALT(0)
END;
CASE type OF
| library:
lib := e.OpenLibrary(name,0);
| device:
unit := 0;
IF st.Occurs(name,"console") = 0 THEN unit := -1 END;
IF e.OpenDevice(name,unit,sys.ADR(ioreq),LONGSET{})=0 THEN
lib := sys.VAL(LONGINT,ioreq.device);
ELSE
lib := NIL
END;
| resource:
lib := e.OpenResource(name);
END;
IF lib = NIL THEN
io.WriteString("Can't open "); io.WriteString(name); io.WriteLn;
HALT(0)
END;
size := lib.negSize;
arg.GetArg(2,str);
IF ~c.StringToInt(str,offs) THEN Usage END;
IF arg.NumArgs() > 2 THEN
arg.GetArg(3,str);
IF ~c.StringToInt(str,lines) THEN Usage END;
ELSE
lines := -1;
END;
io.WriteString(name); io.WriteString(" found at ");
io.WriteHex(lib,8); io.WriteString("H.\n");
offs := offs DIV 6 * 6;
IF (offs < -size) OR (offs > -6) THEN
io.WriteString("Offset out of Range\n");
HALT(0)
END;
ptr := sys.VAL(LONGINT,lib) + offs;
IF ptr.jmp # 04EF9H THEN
io.WriteString("I'm confused with the jump-table\n");
HALT(0);
END;
adr := ptr.adr;
io.WriteString("Routine with offset ");
io.WriteInt(offs,1); io.WriteString(" lies at address ");
io.WriteHex(adr,8); io.WriteString("H.\n\n");
END(*IF*);
IF lines < 0 THEN
IF ~d.IsInteractive(d.Input()) OR ~d.IsInteractive(d.Output()) THEN
lines := 100
END;
END;
IF lines >= 0 THEN
WHILE lines > 0 DO
Break.CheckBreak;
adr := da.Disass(line,adr,0);
io.WriteString(line.s); io.WriteLn;
DEC(lines);
END;
ELSE
REPEAT
lines := 20; WHILE lines > 0 DO
Break.CheckBreak;
adr := da.Disass(line,adr,0);
io.WriteString(line.s); io.WriteLn;
DEC(lines);
END;
io.WriteString("-- More? ");
io.ReadString(str);
io.WriteString("\x0B\r");
UNTIL (CAP(str[0])="N") OR (CAP(str[0])="X") OR (CAP(str[0])="Q");
END;
CLOSE
IF lib # NIL THEN
CASE type OF
library: e.CloseLibrary(lib) |
device: e.CloseDevice(sys.ADR(ioreq))
ELSE
END;
END;
io.WriteString("\[3mCiao Amigos!\[0m\n");
END SysDis.